package com.guguju.ssms.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.guguju.ssms.R;

/**
 * Created by dell on 2022-5-17.
 */
public class ErrorView extends LinearLayout {

    private ImageView ivError;
    private TextView tvError;

    public static final int TYPE_SOUSUO = 1;
    public static final int TYPE_GOUWUCHE = 2;
    public static final int TYPE_TUIJIAN = 3;
    public static final int TYPE_LISHI = 4;
    public static final int TYPE_SHANGJIA = 5;
    public static final int TYPE_SHENFEN = 6;
    public static final int TYPE_DINGDAN = 7;
    public static final int TYPE_JIESUAN_DINGDAN = 8;
    public static final int TYPE_SHANGPIN = 9;
    public static final int TYPE_SHOUYI = 10;
    public static final int TYPE_XIAOXI = 11;
    public static final int TYPE_YAOQINGMA = 12;


    public ErrorView(Context context) {
        super(context);
        init();
    }

    public ErrorView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ErrorView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private void init(){
        inflate(getContext(), R.layout.error_layout, this);
        ivError = (ImageView) findViewById(R.id.iv_error);
        tvError = (TextView) findViewById(R.id.tv_error);
    }

    public void setType(int type){
        switch (type){
            case TYPE_DINGDAN:
                ivError.setImageResource(R.drawable.ic_error_dingdan);
                tvError.setText(R.string.error_dingdan);
                break;
            case TYPE_GOUWUCHE:
                break;
            case TYPE_JIESUAN_DINGDAN:
                break;
            case TYPE_LISHI:
                break;
            case TYPE_SHANGJIA:
                break;
            case TYPE_SHANGPIN:
                ivError.setImageResource(R.drawable.ic_error_shangpin);
                tvError.setText(R.string.error_shangpin);
                break;
            case TYPE_SHENFEN:
                break;
            case TYPE_SHOUYI:
                break;
            case TYPE_SOUSUO:
                ivError.setImageResource(R.drawable.ic_error_sousuo);
                tvError.setText(R.string.error_sousuo);
                break;
            case TYPE_TUIJIAN:
                break;
            case TYPE_XIAOXI:
                break;
            case TYPE_YAOQINGMA:
                break;
        }
    }
}
